﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;


/// <summary>
/// Summary description for Genre
/// </summary>
public class Genre
{
    SqlConnection conn = Utils.getDBConnection();

    private int movie_genre_ID = 0;
    private string genre = null;  


    public Genre()
    {
        //
        // TODO: Add constructor logic here

    }

    /// <summary>
    /// /List of all getters and setter for the customer class
    /// </summary>
    public int MovieGenreID
    {
        get { return movie_genre_ID; }
        set { movie_genre_ID = value; }
    }

    public string MovieGenre
    {
        get { return genre; }
        set { genre = value; }
    }

    


    /// <summary>
    /// Method to get genre details 
    /// </summary>
    /// <param name="user">search text</param>
    /// <returns>Movies object</returns>

    public List<Genre> getGenre()
    {

        //prepare SQL call
        SqlCommand storedProcCommand = new SqlCommand("dbo.mov_getGenreListing", conn);
        storedProcCommand.CommandType = System.Data.CommandType.StoredProcedure;        
        conn.Open();

        //exec SQL
        SqlDataReader reader = storedProcCommand.ExecuteReader();
        List<Genre> results = new List<Genre>();


        //check 
        while (reader.Read())
        {
            Genre gr = new Genre();
            gr.MovieGenreID = (int)reader["movie_genre_ID"];
            gr.MovieGenre = reader["movie_genre"].ToString();         
            results.Add(gr);
        }

        //clean-up
        reader.Close();
        conn.Close();
        return results;
    }





}